import request from '@/utils/request'

export function fetchList(query) {
  return request({
    url: '/api/category/list',
    method: 'get',
    params: query
  })
}

export function fetchListAll(query) {
  return request({
    url: '/api/category/list-all',
    method: 'get',
    params: query
  })
}

export function fetchCategory(id) {
  return request({
    url: '/api/category/detail',
    method: 'get',
    params: { id }
  })
}

export function createCategory(data) {
  console.log(data)
  return request({
    url: '/api/category/create',
    method: 'post',
    data
  })
}

export function updateCategory(data) {
  return request({
    url: '/api/category/update',
    method: 'post',
    data
  })
}

export function deleteCategory(cateId) {
  return request({
    url: '/api/category/delete/' + cateId,
    method: 'post'
  })
}

export function fetchOptionList(query) {
  return request({
    url: '/api/category/list-options',
    method: 'get',
    params: query
  })
}

export function createCategoryOption(data) {
  return request({
    url: '/api/category/create-options',
    method: 'post',
    data
  })
}

export function updateCategoryOption(data) {
  return request({
    url: '/api/category/update-options',
    method: 'post',
    data
  })
}

export function deleteCategoryOption(cateOptionId) {
  return request({
    url: '/api/category/delete-options/' + cateOptionId,
    method: 'post'
  })
}
